/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.sd.chat;

import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.util.UUID;
import java.util.Vector;

/**
 *
 * @author Old
 */
public class RMIServerTool extends UnicastRemoteObject implements RMIServerToolInterface {

    private ServerManager myMan;

    public RMIServerTool(ServerManager manager) throws RemoteException {
        super();
        this.myMan = manager;
    }

    @Override
    public synchronized RMIHandlerInterface registerConnection(RMIHandlerInterface cliHandler) throws RemoteException {
        UUID uniqueKey = UUID.randomUUID();
        RMIConnectionHandler conHandler = new RMIConnectionHandler(uniqueKey, this.myMan, cliHandler);
        this.myMan.newRMIConnection(uniqueKey, conHandler);
        new Thread(conHandler). start ( );
        return conHandler;
    }
}
